import pandas as pd 
import matplotlib.pyplot as plt
dict = {
    'name':['Tom','Bob','Mary','James'],
    'age':[18,30,25,50],
    'city':['Beijing','Shanghai','Guangzhou','Shenzhen']
}
df = pd.DataFrame(dict)
print(df)

df['country'] = 'China'
print(df)

df['adress'] = df['city']+','+df['country']
print(df)

df.columns=['Age','City','Name','County','Address']

df['Score'] = [60,80,90,100]


# df.loc[行标签,列标签]
# print(df.loc[0:2]) #选取 Tom至Mary的所有行的数据，Tom和Mary是index
# print(df.loc[:,'City']) #选取 city 列的数据

# df.iloc[行位置,列位置]    
print(df.iloc[1,1]) #选取第二行，第二列的值，返回的为单个值    
print(df.iloc[[0,2],:]) #选取第一行及第三行的数据    
print(df.iloc[0:2,:]) #选取第一行到第三行（不包含）的数据   
print(df.iloc[:,1]) #选取所有记录的第二列的值，返回的为一个Series   
print(df.iloc[1,:]) #选取第一行数据，返回的为一个Series

print("age mean is {0}".format(df['Age'].mean()))

print("age std is {0}".format(df['Age'].std()))

print("age var is {0}".format(df['Age'].var()))

print(df.T)

df.plot(x='Age',y='Score',use_index=True)

plt.show()
